package cn.yotta.user.web.autoconfiguration.context.header;

import lombok.experimental.UtilityClass;

import java.util.Map;

/**
 * @author wyaoyao
 * @date 2022/11/8 15:01
 */
@UtilityClass
public class CookieContext {

    private static final ThreadLocal<Map<String, String>> COOKIES = new ThreadLocal<>();

    public static void setCookies(Map<String, String> cookies) {
        COOKIES.set(cookies);
    }

    public static Map<String, String> getCookies() {
        return COOKIES.get();
    }

    public static String getCookie(String name) {
        return COOKIES.get() == null ? null : COOKIES.get().get(name);
    }

    public static void clearCookies() {
        COOKIES.remove();
    }
}
